Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hide navigation button when toolbar variant of AppLayout has hideNavigation #2872

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

dpitcock
Copy link
Contributor

@dpitcock dpitcock commented Oct 15, 2024

Description

Overview

Other

  • renaming mergeProps => mergeMultiAppLayoutProps and SharedProps => SharedMultiAppLayoutProps to be more specific and exporting them so they can be tested individually
  • testing the mergeMultiAppLayoutProps in isolation on own unit test file
  • testing the specific case of AppLayout where the navigationHide prop is true with the assertion that no navigation-panel nor navigation toggle is visible.

Related links, issue #, if available: n/a

How has this been tested?

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

codecov bot commented Oct 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.21%. Comparing base (f891e72) to head (8ab819e).
Report is 11 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #2872    +/-   ##
========================================
  Coverage   96.21%   96.21%            
========================================
  Files         761      761            
  Lines       21490    21502    +12     
  Branches     7350     6963   -387     
========================================
+ Hits        20676    20688    +12     
- Misses        761      806    +45     
+ Partials       53        8    -45     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dpitcock dpitcock force-pushed the applayout-controlled-navigation-page branch 2 times, most recently from 3645236 to 3f2d6ef Compare October 16, 2024 17:13
@dpitcock dpitcock force-pushed the applayout-controlled-navigation-page branch from 3f2d6ef to b472120 Compare October 16, 2024 17:21
@dpitcock dpitcock marked this pull request as ready for review October 17, 2024 11:46
@dpitcock dpitcock requested a review from a team as a code owner October 17, 2024 11:46
@dpitcock dpitcock requested review from abdhalees and removed request for a team October 17, 2024 11:46
@dpitcock dpitcock force-pushed the applayout-controlled-navigation-page branch from 1568590 to 24d2456 Compare October 17, 2024 14:05
//navigation must be null if hidden so toolbar knows to hide the toggle button
const resolvedNavigation = navigationHide ? null : navigation ?? <></>;
//navigation must not be open if navigationHide is true
const resolvedNavigationOpen = !!resolvedNavigation && navigationOpen;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if no navigation provided, the fragment passed will be truthy, therefor resolvedNavigation will only be falsy if navigationHide is true


export default function () {
const {
urlParams: { navigationOpen = true, navigationHide = false },
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we can easily set expectations in regression tests

@@ -10,7 +10,7 @@ import { AppLayoutProps } from '../interfaces';
import { Focusable } from '../utils/use-focus-control';
import { SplitPanelToggleProps, ToolbarProps } from './toolbar';

interface SharedProps {
export interface SharedMultiAppLayoutProps {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only name changes for the interface and function

{...defaultAppLayoutProps}
data-testid="first"
navigation="testing nav"
navigationHide={true}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second layout using navigationHide is a more common case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the test name and added some assertions below to cover this case more thoroughly.

Copy link
Member

@just-boris just-boris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small comments only

@@ -0,0 +1,109 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
/* eslint-disable simple-import-sort/imports */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only do this in files which use src/app-layout/__tests__/utils.tsx because it contains side effects.

All other tests can benefit from the linter rule

Comment on lines +91 to +94
expect(firstLayout.findNavigation()).toBeFalsy();
expect(firstLayout.findNavigationToggle()).toBeFalsy();
expect(secondLayout.findNavigation()).toBeFalsy();
expect(secondLayout.findNavigationToggle()).toBeFalsy();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we test here?

Is it about navigationHide is respected, even if navigation is defined? Then we should call it in the test name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants